<?php

namespace App\Http\Controllers\Test;

use App\Http\Controllers\Controller;
use App\Models\Admin;
use App\Models\Article;

class AdminController extends Controller
{

    // 简单的测试
    public function initialize()
    {
        parent::initialize();
    }

    // 删除二维数组最后一个元素
    public function lists()
    {
        $model  = new Admin();
        $data   = $model->isCache(true)->getAll();
        $sql    = $model->getSql();
        $result = ['sql' => $sql, 'data' => $data,];

        return $this->success($result);
    }

    // 修改用户名的密码
    public function password()
    {
        $username = $this->getData('username');
        $model    = new Admin();

        $where = ['username' => $username];
        $data  = ['password' => 123456,];
        $data  = $model->checkData($data, $where);
        $this->throwIf($data === false, $model->getError());

        $result = $model->oneEdit($where, $data);

        return $this->success($result);
    }

}


